<template>
	<view class="logoinBox">		
		<view class="logoinBox_item">
			<uni-icons class="user" type="contact" size="100" ></uni-icons>
			<button type="primary" class="button" open-type="getUserInfo" @click="getuser" >一键登录</button>
			<text class="text">登录后享受更多权益</text>
		</view>
	</view>
</template>

<script>
	import {mapState,} from 'vuex'
	export default {
		name:"my-logoin",
		data() {
			return {};
		},
		methods:{
			getuser(){
				uni.getUserProfile({
				      desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
				    }).then(res=>{
						if(res[0]==null&&res.length==2){
							this.$store.commit('user/setuserobj',res[1]);
								uni.login().then(res=>{
									if(res[0]==null&&res.length==2){
										this.$store.commit('user/setUserCode',res[1].code)
									}
								})
						}
					})
			}
		},
	}
</script>

<style lang="scss" >
.logoinBox{display: flex;justify-content: space-around;flex-direction: column;align-items: center;text-align: center;}
.logoinBox_item{position:absolute;top:50%;left: 50%;transform: translateX(-50%)translateY(-50%);width:480rpx;}
.text{color: #ccc;font-size:22rpx;padding-top:10rpx;}
.button{width: 90%;border-radius:100rpx;background-color:#c00;}
</style>
